package com.assistant.admin.service.impl;


import com.assistant.admin.service.VisualizationService;
import com.assistant.mapper.AddressPosterMapper;
import com.assistant.mapper.PostItemsMapper;
import com.assistant.pojo.AddressPoster;
import com.assistant.pojo.ItemsPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class VisualizationServiceImpl implements VisualizationService {
    @Autowired
    private PostItemsMapper postItemsMapper;
    @Autowired
    private AddressPosterMapper addressPosterMapper;

    public List<Map<String, String>> getKindOfnum() {
        List<Map<String, String>> lst = new ArrayList<>();
        ItemsPost itemsPost = new ItemsPost();

        itemsPost.setKind(2);
        int studyNum = postItemsMapper.selectCount(itemsPost);
        Map<String, String> map1 = new HashMap<String, String>();
        map1.put("value", String.valueOf(studyNum));
        map1.put("name", "学习");
        lst.add(map1);

        itemsPost.setKind(1);
        int lifeNum = postItemsMapper.selectCount(itemsPost);
        Map<String, String> map2 = new HashMap<String, String>();
        map2.put("value", String.valueOf(lifeNum));
        map2.put("name", "生活");
        lst.add(map2);


        itemsPost.setKind(4);
        int makeUpNum = postItemsMapper.selectCount(itemsPost);
        Map<String, String> map3 = new HashMap<String, String>();
        map3.put("value", String.valueOf(makeUpNum));
        map3.put("name", "化妆品");
        lst.add(map3);

        itemsPost.setKind(3);
        int electronicNum = postItemsMapper.selectCount(itemsPost);
        Map<String, String> map4 = new HashMap<String, String>();
        map4.put("value", String.valueOf(electronicNum));
        map4.put("name", "电子");
        lst.add(map4);

        itemsPost.setKind(5);
        int OtherNum = postItemsMapper.selectCount(itemsPost);
        Map<String, String> map5 = new HashMap<String, String>();
        map5.put("value", String.valueOf(OtherNum));
        map5.put("name", "其他");
        lst.add(map4);
        return lst;
    }

    public List<String[]> getDormitoryNum() {
        List<String[]> arr = new ArrayList<>();
        String []arr1 = {"紫薇楼", "金桂园", "橙萱居" ,"书院楼", "蓝楹楼", "红棉楼", "黄槐楼"};
        AddressPoster addressPoster = new AddressPoster();
        addressPoster.setFloor("紫薇楼");
        int one = addressPosterMapper.selectCount(addressPoster);
        addressPoster.setFloor("金桂园");
        int two = addressPosterMapper.selectCount(addressPoster);
        addressPoster.setFloor("橙萱居");
        int three = addressPosterMapper.selectCount(addressPoster);
        addressPoster.setFloor("书院楼");
        int fourth = addressPosterMapper.selectCount(addressPoster);
        addressPoster.setFloor("蓝楹楼");
        int five = addressPosterMapper.selectCount(addressPoster);
        addressPoster.setFloor("红棉楼");
        int six = addressPosterMapper.selectCount(addressPoster);
        addressPoster.setFloor("黄槐楼");
        int seven = addressPosterMapper.selectCount(addressPoster);
//        String[] arr2 = {String.valueOf(one), String.valueOf(two), String.valueOf(three), String.valueOf(fourth), String.valueOf(five), String.valueOf(six), String.valueOf(seven)};
        String []arr2 = {"677","988","455","677","344","345","342"};
        arr.add(arr1);
        arr.add(arr2);
        return arr;
    }


}
